package lab02.test06;

import static java.lang.Math.sqrt;

public class Triangle {
    double edge1;
    double edge2;
    double edge3;
    double circumference;
    double area;

    public double getEdge1() {
        return edge1;
    }

    public void setEdge1(double edge1) {
        this.edge1 = edge1;
    }

    public double getEdge2() {
        return edge2;
    }

    public void setEdge2(double edge2) {
        this.edge2 = edge2;
    }

    public double getEdge3() {
        return edge3;
    }

    public void setEdge3(double edge3) {
        this.edge3 = edge3;
    }

    public double countCircumference() {
        circumference = edge1 + edge2 + edge3;
        return circumference;
    }

    public double countArea() {
        circumference = edge1 + edge2 + edge3;
        area = Math.sqrt(circumference/2*(circumference/2-edge1)*(circumference/2-edge2)*(circumference/2-edge3));
        return area;
    }

    public void modifyEdge1(double edge) {
        this.edge1 = edge;
    }
    public void modifyEdge2(double edge) {
        this.edge2 = edge;
    }
    public void modifyEdge3(double edge) {
        this.edge3 = edge;
    }

    public boolean Boolean() {
        if(edge1<edge2+edge3 && edge2<edge1+edge3 && edge3<edge1+edge2) {
            return true;
        }else {
            return false;
        }
    }

    Triangle() {}

    @Override
    public String toString() {
        return "周长 = " + circumference + "\n" + "面积 = " + area + "\n" + "是否三角形：" + Boolean();
    }
}
